/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
 * Description: gradient Split Tune module cluster header file
 * Author: qianglihong
 * Create: 2020-09-15
 */

#ifndef AUTO_TUNING_CLUSTER_H
#define AUTO_TUNING_CLUSTER_H

#include <iostream>
#include <vector>
#include <typeinfo>
#include <sstream>
#include <fstream>
#include "topology.h"
#include <cmath>
#include "base.h"
#include "log.h"
#include "hcom_pub.h"

constexpr double EPSILON = 1e-6; /* 双精度比较可接受的误差 */

class Cluster {
public:
    explicit Cluster(std::string workPath, int gpuNum = 16, float fixedJetter = 0);

    ~Cluster();

    float CalculateCost(const Communication &op, float size = 0, float divisor = 1);

    float CalculateCostWithJetter(const Communication &op, float size, float fixedJetter = 0, float divisor = 1);

    float CalculateStartUpCost(const Communication &op, float size = 0, float divisor = 1);

private:
    float mFixedJetter_;
    int gpuNum_;
    int mDeviceMemory_;
    std::vector<Topology> mTopoList_;
    std::vector<int> mTopoNumList_;
};


#endif
